var _inherit = require('core/inherit.js');
var _Container = require('component/container.js');
var _layout = require('tools/layout.js');
var _relative = _layout.relative;

var _vec4f = require('core/glm.js').vec4f;
var _Materials = require('global/materials.js');
var TWEEN = require('third_party/tweenjs/tween.js');

var _Constance = require('./constance.js');
var _global = require('global/global.js');
var S = require('res/style.js');

// ==========================
// NoMove
// ==========================
function NoMove() {
    _Container.call(this);
    this.setId('outofmove');

    this.addChild(this.mText = S.game.header.outofmove.createText('Out of moves!'));
    this.mText.setAnchor(0.5, 0.5);

    this.mColor = new _vec4f(1, 1, 1, 1);
    this.mAlpha = new _vec4f();

    this.alpha = 0;
    this.layout();
}
_inherit(NoMove, _Container);
NoMove.prototype.layout = function () {
    this.setSize(_Constance.headerSize);
    _relative.local.layoutTo(this.mText, 0.5, 0.5, this, 0.618, 0.5);
};
NoMove.prototype.show = function () {
    return new TWEEN.Tween(this).to({alpha: 1}, 0.66);
//    return new TWEEN.Tween(this).to({alpha: 1}, 6);
};
NoMove.prototype.recoverFromLostContext = function (context) {
    this.mText.draw(context);
};
NoMove.prototype.drawContent = function (context) {
    this.mColor.scale(this.alpha, this.mAlpha);
    _Materials.globalColor(this.mAlpha);
    this.mText.draw(context);
    _Materials.globalColor(this.mColor);
};

module.exports = NoMove;